message(NOTICE "开始 java 模块")
# 检查构建目标是否存在
if(TARGET jvm-${JVN_TAG})
    message(NOTICE "jvm 模块已存在 jvm-${JVN_TAG}")
    return()
endif()
# 构建 jvm 库
ExternalProject_Add(
    jvm-${JVN_TAG}
    PREFIX         ${EXTERNAL_PROJECT_ROOT}                # ✅ 显式设置 prefix 目录
    SOURCE_DIR     ${MODULE_SRC}/jvm/${JVN_TAG}          # ✅ 显式设置 source 目录
    BINARY_DIR     ${MODULE_BUILD}/jvm/${JVN_TAG}        # ✅ 显式设置 build 目录
    INSTALL_DIR    ${MODULE_INSTALL_DIR}/jvm/${JVN_TAG}  # ✅ 显式设置 install 目录
    STAMP_DIR      ${MODULE_STAMP}/jvm/${JVN_TAG}        # ✅ 显式设置 stamp 目录
    TMP_DIR        ${MODULE_TMP}/jvm/${JVN_TAG}          # ✅ 显式设置 tmp 目录

    DOWNLOAD_COMMAND # 下载命令
        COMMAND ${CMAKE_COMMAND}
            -DSOURCE_DIR=<SOURCE_DIR>
            -DGIT_REPOSITORY=${JVN_REPO}
            -DGIT_TAG=${JVN_TAG}
            -P ${__DIR}/utils/git.cmake

    # 禁用后续阶段
    CONFIGURE_COMMAND  ""                          # 跳过 configure
    BUILD_COMMAND      ""                          # 跳过 build
    INSTALL_COMMAND    ""                          # 跳过 install
    TEST_COMMAND       ""                          # 跳过 test
    # ✅ 启用所有日志（调试必备）
    LOG_DOWNLOAD      OFF                           # 下载日志
    LOG_CONFIGURE     OFF                           # 配置日志
    LOG_BUILD         OFF                           # 构建日志
    LOG_INSTALL       OFF                           # 安装日志
    LOG_OUTPUT_ON_FAILURE OFF                       # 失败时自动输出日志
    STEP_TARGETS       download                    # 可通过 make download 触发
    EXCLUDE_FROM_ALL   YES                         # 可选：不加入 all 目标
)
# 创建导入目标
add_library(jvm::jvm SHARED IMPORTED FORCE)
# 导入目标属性设置
set_target_properties(jvm::jvm PROPERTIES
    VERSION ${JVN_TAG}
    IMPORTED_LOCATION ${MODULE_SRC}/jvm/${JVN_TAG}/lib/server/libjvm.so
    INTERFACE_INCLUDE_DIRECTORIES "${MODULE_SRC}/jvm/${JVN_TAG}/include;${MODULE_SRC}/jvm/${JVN_TAG}/include/linux"
)
#依赖库
add_dependencies(jvm::jvm jvm-${JVN_TAG})


